package com.greensam.pixelengine.api.imagesearch;

import com.greensam.pixelengine.api.imagesearch.model.ImageSearchResult;
import com.greensam.pixelengine.api.imagesearch.sub.GetImageFirstUrlApi;
import com.greensam.pixelengine.api.imagesearch.sub.GetImageListApi;
import com.greensam.pixelengine.api.imagesearch.sub.GetImagePageUrlApi;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @author Ma Chengrui
 * @since 2025/9/17 10:32
 */
@Slf4j
public class ImageSearchApiFacade {

    public static List<ImageSearchResult> searchImage(String imageUrl) {
        String imagePageUrl = GetImagePageUrlApi.getImagePageUrl(imageUrl);
        String imageFirstUrl = GetImageFirstUrlApi.getImageFirstUrl(imagePageUrl);
        return GetImageListApi.getImageList(imageFirstUrl);
    }

    public static void main(String[] args) {
        List<ImageSearchResult> imageSearchResults = searchImage("https://picture-1317641405.cos.ap-guangzhou.myqcloud.com/Greensam/private/1/2025-09-16_2J2sR69puXQm.jpg");
        System.out.println("搜索成功" + imageSearchResults);
    }
}
